//
//  HMRealName.m
//  SNS_Login-register
//
//  Created by hy on 2021/10/29.
//  Copyright © 2021 lzxuan. All rights reserved.
//

#import "HWUserView.h"
#import "HWGameMgr.h"
#import "HWConstant.h"

@interface HWUserView()

@property (weak, nonatomic) IBOutlet UILabel *title;
@property (weak, nonatomic) IBOutlet UILabel *tips;

@property (weak, nonatomic) IBOutlet UILabel *userAccountText;
@property (weak, nonatomic) IBOutlet UILabel *phoneText;
@property (weak, nonatomic) IBOutlet UIButton *bindBtn;
@property (weak, nonatomic) IBOutlet UIButton *exitBtn;
@end

@implementation HWUserView


+ (instancetype)HWUserView{
    NSString  *clsName = NSStringFromClass([self class]);
    UINib * nib = [UINib nibWithNibName:clsName bundle:nil];
    HWUserView * obj = [nib instantiateWithOwner:nil options:nil].firstObject;
    [obj initGameView];
    return obj;
    
}

-(void)updateData:(NSDictionary*)dic{
    _bindBtn.hidden = true;
    self.userAccountText.text = [dic objectForKey:@"username"];
    NSString* pStr = [dic objectForKey:@"phoneNumber"];
    if (pStr==NULL || [pStr isEqualToString:@""]) {
        pStr = @"绑定手机(未绑定)";
        _bindBtn.hidden = false;
    }
    self.phoneText.text = pStr;
}

-(void)initGameView{
//    // 创建一个富文本对象
//    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
//    // 设置富文本对象的颜色
//    attributes[NSForegroundColorAttributeName] = [UIColor grayColor];
//    _userAccountTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入账号" attributes:attributes];
//    _phoneTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入手机号" attributes:attributes];
//    _idTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:attributes];
}

#pragma mark - 提交
- (IBAction)bindBtnClick:(id)sender {
    self.hidden = true;
    if (!kUseJs) {
        [[HWGameMgr shared] hiddenBall];
    }
    [[HWGameMgr shared] showBindPhoneVew:self.userAccountText.text];
}

#pragma mark - 提交
- (IBAction)exitBtnClick:(id)sender {
    [[HWGameMgr shared] callToJsWithMethed:kSDKExitCallBack andDic:@{}];
}


#pragma mark - 关闭
- (IBAction)closeBtnClick:(id)sender {
    if (!kUseJs) {
        [[HWGameMgr shared] showBall];
    }
    self.hidden = true;
}

- (void)switchToLogin{
//    _title.text = @"登录";
//    _tips.text = @"没有账号？点此";
//    [_switchBtn setTitle:@"注册" forState:UIControlStateNormal];
//    [_switchBtn setTitle:@"注册" forState:UIControlStateSelected];
//    [_regLoginBtn setTitle:@"登录" forState:UIControlStateNormal];
//    [_regLoginBtn setTitle:@"登录" forState:UIControlStateSelected];
}



#pragma mark - 点击事件
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        //収键盘
//    [self.userAccountTextField resignFirstResponder];
//    [self.phoneTextField resignFirstResponder];
//    [self.idTextField resignFirstResponder];
}

@end
